package net.tngou.crawler.enterprise;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import net.tngou.c4j.util.HttpUtil;
import net.tngou.crawler.pojo.Enterprise;
import net.tngou.crawler.pojo.POJO;

public class EnterpriseTest {

	public static void main(String[] args) {
		@SuppressWarnings("unchecked")
		List<Enterprise> list = (List<Enterprise>) new Enterprise().list(); 
		for (Enterprise enterprise : list) {
			System.err.println(enterprise.getName());
			Map<String, String> data=new HashMap<>();
			data.put("name", enterprise.getName());
			String sjson = HttpUtil.postString("http://20m42i4998.imwork.net:23399/spider/api/enterprise", data);
			JSONObject json = JSON.parseObject(sjson);
			if(json.getBooleanValue("status")) {
				Enterprise e = JSON.parseObject(sjson, Enterprise.class);
				e.setId(enterprise.getId());
				e.update();
			}
		}
	}
}
